import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        int left = 0;
        int max = 0;
        for(int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        for(int i = 1; i < n; i++) {
            if(arr[i] - arr[i - 1] > 1 || arr[i] - arr[i - 1] < -1) {
                left = i;
            }
            max = Math.max(max,i - left);
        }
        System.out.println(max + 1);
    }
}
